<?php
/**
 * Created by PhpStorm.
 * User: yyq
 * Date: 2018/10/21
 * Time: 21:05
 */

namespace Web\Controller;


use Common\Model\AddressModel;

class AddressController extends WebbaseController
{
    private $address_model;
    private $member_info;

    public function __construct()
    {
        parent::__construct();
        $this->address_model    = new AddressModel();
        $this->member_info      = $_SESSION['member_info'];
    }

    public function address_list() {
        $result = $this->address_model->where(['mid' => $this->member_info['mid']])->select();

        $this->assign('lists', $result);
        $this->assign('sale_code', I('get.sale_code'));
        $this->display();
    }

    public function delAddr() {
        $addr_id = I('post.addr_id');

        if($this->address_model->delete($addr_id)) {
            exit($this->returnApiSuccess());
        } else {
            exit($this->returnApiError(WebbaseController::FATAL_ERROR, '添加失败，请重试'));
        }
    }
}